/**
 * DNATools.cpp
 *
 *  Created on: Apr 19, 2011
 *  Updated: Apr 27, 2011
 *
 *  Author: James Harding, Dillon Graham
 *
 * This class performs operations on objects of the DNA type. It also contains
 * static functions that perform pairwise comparisons of dna sequences.
 *
 * Usage:
 * C:/(directory)>(program).exe <File1> <File2> <gapPenalty>
 *
 * ie. BioInfo.exe Data1.txt Data2.txt -2
 *
 */

#include <iostream>
#include <stdio.h>
#include <vector>
#include "Main.h"
#include "DNA.h"
#include "FileIO.h"
#include "CompareDNA.h"

using namespace std;


/**takes 5 arguements patient1 patient2
 *outputfilename gappenalty and datasetfilepath
 */

int main(int argc, char *argv[]) {
    ///Creates the file input
    FileIO *input = new FileIO();

    //int penalty = atoi(argv[3]);
    FileIO::CreateOutputFile(argv[3]);

    ///creating a list of files
    vector<string> FileList(input->readFolder(argv[5]));

    ///creating a vector of DNA from the files above
    vector<DNA*> DNAList(FileList.size());
    for (int i = 0; i < (int)FileList.size(); i++) {
            input->ChangeFile(FileList[i]);
            DNAList[i] = new DNA(input->read());
        }

    ///creating a comparable object
	CompareDNA *MyComparableDNA = new CompareDNA();
	MyComparableDNA->standardScoringMatrix();

    ///creating the distance matrix
	cout << "Creating Distance Matrix..." << endl;
	MyComparableDNA->initializeDistanceMatrix((int)DNAList.size());

    for(int i = 0; i < (int)DNAList.size(); i++){
    	for(int j = 0; j < (int)DNAList.size(); j++){
    		if(j > i){
    		MyComparableDNA->NeedlemanWunsch(DNAList[i], DNAList[j], -2);
    		MyComparableDNA->setValueInDistanceMatrix(i, j);
    		}
    	}
    }

    MyComparableDNA->printDistanceMatrix();
/*
	//Dynamically allocating my DNA sequences

	FileIO::ChangeFile(argv[1]);
	DNA *Dentist = new DNA(input->read());

	FileIO::ChangeFile(argv[2]);
	DNA *Patient = new DNA(input->read());

    //using the NeedlemanWunsch function
    cout << "Starting Needleman/Wunsch" << endl;
    MyComparableDNA->NeedlemanWunsch(Dentist, Patient, -2);
    MyComparableDNA->printTwoAlignedSequences(Dentist, Patient, "Needleman/Wunsch");

    //using the SmithWaterman function
    cout << "Starting Smith-Waterman" << endl;
    MyComparableDNA->SmithWaterman(Dentist, Patient, -2, -1);
    MyComparableDNA->printTwoAlignedSequences(Dentist, Patient, "Smith-Waterman");

    cout << endl << "done" << endl;*/
    FileIO::Write("done");

    //delete Dentist;
    //delete Patient;
    delete input;


}
